﻿@page "/files/upload"
@attribute [Authorize]

<div class="card">
    <div class="card-header">
        Upload File
    </div>
    <div class="card-body">
        <EditForm EditContext="@EditContext" OnValidSubmit="HandleValidSubmit">

            <DataAnnotationsValidator />
            <ValidationSummary />

            <div class="form-group row">
                <label for="fileName" class="col-sm-2 col-form-label">Name: </label>
                <div class="col-sm-10">
                    <InputText id="fileName" class="form-control" @bind-Value="File.Name" placeholder="Enter Name"></InputText>
                    <ValidationMessage For="@(() => File.Name)" />
                </div>
            </div>

            <div class="form-group row">
                <label for="description" class="col-sm-2 col-form-label">Description: </label>
                <div class="col-sm-10">
                    <InputText id="description" class="form-control" @bind-Value="File.Description" placeholder="Enter Description"></InputText>
                    <ValidationMessage For="@(() => File.Description)" />
                </div>
            </div>
            <div class="form-group row">
                <label for="formFile" class="col-sm-2 col-form-label">File (JSInterop)</label>
                <div class="col-sm-10">
                    <input type="file" id="formFile"
                           name="formFile"
                           onchange="interop.fileSelected(this)"
                           class="form-control" />
                </div>
            </div>
            <div class="form-group row">
                <label for="formFile" class="col-sm-2 col-form-label">File (InputFile)</label>
                <div class="col-sm-10">
                    <InputFile OnChange="@OnInputFileChange" class="form-control" />
                </div>
            </div>
            <div class="form-group row">
                <label for="encrypted" class="col-sm-2 col-form-label">Encrypted</label>
                <div class="col-sm-10">
                    <InputCheckbox id="encrypted" @bind-Value="File.Encrypted" />
                </div>
            </div>
            <div class="form-group row">
                <label for="description" class="col-sm-2 col-form-label"></label>
                <div class="col-sm-10">
                    <button class="btn btn-primary">Save</button>
                </div>
            </div>
        </EditForm>
    </div>
    <div class="card-footer">
        <a class="btn btn-outline-secondary"
           href="@("/files")"
           style="width: 80px;">
            <i class="fa fa-chevron-left"></i> Back
        </a>
    </div>
</div>
